//
//  GrantListContentTableViewCell.m
//  FactorySale
//
//  Created by 主事丫环 on 2020/3/26.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "GrantListContentTableViewCell.h"
@interface GrantListContentTableViewCell()
@property (nonatomic, strong) UILabel *phoneTitleLabel;    //配件名称 标题
@property (nonatomic, strong) UIButton *phoneButton;    //配件名称 内容
@end
@implementation GrantListContentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setFrame:(CGRect)frame{
    frame.origin.x += 10;
    frame.size.height -= 10;
    frame.size.width -= 20;
    [super setFrame:frame];
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        UIView *bottomV = [[UIView alloc] init];
        bottomV.backgroundColor = [UIColor whiteColor];
        bottomV.frame = CGRectMake(0, 0, KWIDTH-20, 150);
        bottomV.layer.cornerRadius = 10;
        //bottomV.layer.masksToBounds = YES;
        //bottomV.layer.borderWidth = 1;
        //bottomV.layer.borderColor = [UIColor colorWithHexString:@"#70BE68"].CGColor;
        [self.contentView addSubview:bottomV];
        
        //订单编号
        UILabel *orderNumLab = [[UILabel alloc] init];
        orderNumLab.frame = CGRectMake(10, 10.5, KWIDTH/2, 17);
        orderNumLab.font = KFontPingFangSCRegular(12);
        orderNumLab.textColor = K999999;
        [bottomV addSubview:orderNumLab];
        self.orderNumLab = orderNumLab;
        //右上角 图片
        UIImageView *tipsImg = [[UIImageView alloc] init];
        tipsImg.frame = CGRectMake(bottomV.right-47.5, 3.5, 47.5, 20);
        [bottomV addSubview:tipsImg];
        self.tipsImg = tipsImg;
        //灰色 分割线
        UILabel *line = [[UILabel alloc] init];
        line.frame = CGRectMake(0, orderNumLab.bottom +5, KWIDTH-20, 1);
        line.backgroundColor = [UIColor colorWithHexString:@"#E5E5E5"];
        [bottomV addSubview:line];
        
        //配件名称 标题
        UILabel *pjmcTitLab = [[UILabel alloc] init];
        pjmcTitLab.frame = CGRectMake(10, orderNumLab.bottom +16, 70, 20);
        pjmcTitLab.text = @"配件名称:";
        pjmcTitLab.font = KFontPingFangSCMedium(13);
        pjmcTitLab.textColor = K666666;
        [bottomV addSubview:pjmcTitLab];
        self.pjmcTitLab = pjmcTitLab;
        //配件名称 内容
        UILabel *pjmcConLab = [[UILabel alloc] init];
        pjmcConLab.frame = CGRectMake(pjmcTitLab.right, orderNumLab.bottom +16, KWIDTH-20-12-48-12-70-12, 20);
        pjmcConLab.font = KFontPingFangSCMedium(13);
        pjmcConLab.textColor = K999999;
        [bottomV addSubview:pjmcConLab];
        self.pjmcConLab = pjmcConLab;
        
        
        //故障描述 标题
        UILabel *gzmsTitLab = [[UILabel alloc] init];
        //gzmsTitLab.backgroundColor = [UIColor yellowColor];
        gzmsTitLab.frame = CGRectMake(10, pjmcConLab.bottom +2, 70, 20);
        gzmsTitLab.text = @"故障描述:";
        gzmsTitLab.font = KFontPingFangSCMedium(13);
        gzmsTitLab.textColor = K666666;
        [bottomV addSubview:gzmsTitLab];
        self.gzmsTitLab = gzmsTitLab;
        //故障描述 内容
        UILabel *gzmsConLab = [[UILabel alloc] init];
        gzmsConLab.frame = CGRectMake(gzmsTitLab.right, pjmcConLab.bottom +2, KWIDTH-20-10-70, 20);
        gzmsConLab.font = KFontPingFangSCMedium(13);
        gzmsConLab.textColor = K999999;
        [bottomV addSubview:gzmsConLab];
        self.gzmsConLab = gzmsConLab;
        
        //申请补助金金额 标题
        UILabel *bzjTitLab = [[UILabel alloc] init];
        bzjTitLab.frame = CGRectMake(10, gzmsTitLab.bottom +2, 100, 20);
        bzjTitLab.text = @"申请补助金金额:";
        bzjTitLab.font = KFontPingFangSCMedium(13);
        bzjTitLab.textColor = K666666;
        [bottomV addSubview:bzjTitLab];
        self.bzjTitLab = bzjTitLab;
        //申请补助金 内容
        UILabel *bzjConLab = [[UILabel alloc] init];
        bzjConLab.frame = CGRectMake(bzjTitLab.right, gzmsTitLab.bottom +2, KWIDTH-20-12-48-12-100-12, 20);
        bzjConLab.font = KFontPingFangSCMedium(13);
        bzjConLab.textColor = K999999;
        [bottomV addSubview:bzjConLab];
        self.bzjConLab = bzjConLab;
        
        self.phoneTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, bzjTitLab.bottom +2, 80, 20)];
        self.phoneTitleLabel.text = @"师傅手机号:";
        self.phoneTitleLabel.font = KFontPingFangSCMedium(13);
        self.phoneTitleLabel.textColor = K666666;
        [bottomV addSubview:self.phoneTitleLabel];
        
        self.phoneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.phoneButton.frame = CGRectMake(self.phoneTitleLabel.right, bzjConLab.bottom +2, 200, 20);
        self.phoneButton.titleLabel.font = [UIFont boldSystemFontOfSize:13];
        [self.phoneButton setTitleColor:[UIColor colorWithHexString:@"#1EB491"] forState:UIControlStateNormal];
        self.phoneButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self.phoneButton addTarget:self action:@selector(phoneButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [bottomV addSubview:self.phoneButton];
    }
    return self;
}

- (void)refasf:(GrantListContentModel *)model{
    self.orderNumLab.text = [NSString stringWithFormat:@"%@%@", @"订单编号:", model.id]; //订单编号
    self.pjmcConLab.text = model.parts_name; //配件名称
    self.gzmsConLab.text = model.faultDetails; //故障描述
    self.bzjConLab.text = [NSString stringWithFormat:@"%@%@", @"¥",model.compensationPrice]; //补助金金额
    [self.phoneButton setTitle:model.repairPhone forState:UIControlStateNormal];
    
    if ([model.status isEqualToString:@"0"]) {
        [self.tipsImg setImage:imgname(@"Pending")];
    } else {
        [self.tipsImg setImage:imgname(@"completed")];
    }
}
- (void)phoneButtonClick{
    [HFTools callMobilePhone:self.phoneButton.titleLabel.text];
}
@end
